package com.muli.muwai.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ser.Serializers;
import com.muli.muwai.controller.DataimportController;
import com.muli.muwai.entity.IntfContract;
import com.muli.muwai.entity.TraceTable;
import com.muli.muwai.mapper.TraceTableMappper;
import com.muli.muwai.service.TraceTableService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

@Service
public class TraceTableServiceImpl extends ServiceImpl<TraceTableMappper, TraceTable> implements TraceTableService {

    private static Logger logger = Logger.getLogger(TraceTableServiceImpl.class);
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveTraceTable(List<TraceTable> traceTable) {
        try {
            saveBatch(traceTable);
        } catch (Exception e) {
            logger.error("客户跟踪表插入数据失败");
        }
    }

    @Override
    public void delectdata() {
        //删除9月1号之后的数据
        String s = "2020-09-01";
        QueryWrapper<TraceTable> queryWrapper = new QueryWrapper();
        queryWrapper.gt("creation_time", s);
        int i = 0;
        try {
            i = baseMapper.delete(queryWrapper);
        } catch (Exception e) {
            logger.error("客户跟踪表删除数据库数据9月1号之后的数据失败");
        }
        System.out.println(i);
    }
}
